﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using EZCRS.HCMS.Bll.AIR;
using EZCRS.HCMS.Bll;
using EZCRS.HCMS.Web;

namespace EZCRS.HCMS.Web.manage.booklog
{
    public partial class bookdetail : System.Web.UI.Page
    {
        public string RoomCode, RateCode,StartDate,EndDate;
        int pid;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!Page.IsPostBack)
            {
                int id = CFun.RequestNumber("id");
                if (id > 0)
                {
                    DataRow dr = new BllBookLogView().GetBookLog(id);
                    if (dr != null)
                    {
                        ddlgetstatus.DataSource = DataAcl.Common.BookingStatus();
                        ddlgetstatus.DataTextField = "Value";
                        ddlgetstatus.DataValueField = "Key";
                        ddlgetstatus.DataBind();
                        ddlgetstatus.SelectedValue = "0";

                        ddlstatus.DataSource = DataAcl.Common.BookStatus();
                        ddlstatus.DataTextField = "Value";
                        ddlstatus.DataValueField = "Key";
                        ddlstatus.DataBind();
                        ddlstatus.SelectedValue = "0";

                        LabConfirm.Text = dr["confnum"].ToString();
                        LabRooms.Text = dr["rooms"].ToString();
                        LabCheck.Text = dr["indate"].ToString()+" - "+dr["outdate"].ToString();
                        LabTrueName.Text = dr["guestlastname"].ToString() + " " + dr["guestfirstname"].ToString();
                        LabCreateDate.Text = dr["updatetime"].ToString();
                        LabAddress.Text = dr["guestaddress"].ToString();
                        LabTelphone.Text = dr["guestphone"].ToString();
                        LabHotel.Text = dr["title"].ToString();
                        LabRoomName.Text = dr["RoomName"].ToString();
                        LabCXL.Text = dr["CXLdesc"].ToString();
                        LabGUA.Text = dr["GUAdesc"].ToString();

                        ddlgetstatus.SelectedValue = dr["getstatus"].ToString();
                        ddlstatus.SelectedValue = dr["status"].ToString();

                        RoomCode = dr["RoomType"].ToString();
                        RateCode = dr["RateClass"].ToString();
                        StartDate = dr["indate"].ToString();
                        EndDate = dr["outdate"].ToString();
                        pid = Convert.ToInt32(dr["property_id"].ToString());
 
                    }
                }
            }
        }

        protected void btnConf_Click(object sender, EventArgs e)
        {
            string bookstatus = DataAcl.Common.BookStatus(ddlstatus.SelectedValue);
            string bookgetstatus = ddlgetstatus.SelectedValue;
            int id = CFun.RequestNumber("id");

            if (new BllBookLogView().UpdateStatus(bookstatus, bookgetstatus,LabRooms.Text,RoomCode,RateCode,StartDate,EndDate, id,pid))
            {
                Response.Write(CFun.AlertMeg("订单状态修改成功！", "non", ""));
            }
            else
            {
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
            }
        }
    }
}
